package com.lgl.allpeoplevent.util.service;

import com.lgl.scsapi.util.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Calendar;

/**
 * 工具service
 */

@Service
public class UtilService {
	@Autowired
	private RedisTemplate redisTemplate;
	//@Resource(name = "daoSupport")
	//private DaoSupport dao;

	/**
	 * 异步设置用户登录状态
	 * @param userId 用户ID
	 */
	@Async
	public void asyncSetLoginStatus(String userId){
		long id = Long.valueOf(userId);
		Calendar calendar = Calendar.getInstance();
		int day = calendar.get(Calendar.DAY_OF_MONTH), month = calendar.get(Calendar.MONTH) + 1;
		redisTemplate.opsForValue().setBit(Constants.V_USER_LOGIN_SET_PRE + month + day,id,true);
	}
}